from django.db import models

# Create your models here.

class Store(models.Model):
    name = models.CharField(max_length=255, blank=False)
    store_public_key = models.TextField()
    created_time = models.DateTimeField(auto_now_add=True)
    stonepay_private_key = models.TextField()
    stonepay_public_key = models.TextField()
    aes_key = models.TextField(blank=False)

class Payment(models.Model):
    STATUS = (
        ("S", "Success"),
        ("F", "Fail")
    )
    store = models.ForeignKey(
        Store,
        blank=False,
        on_delete=models.CASCADE,
        related_name='payment_list'
    )
    out_order_id = models.TextField(verbose_name="商店订单号")
    notify_url = models.TextField(verbose_name="异步回调链接")
    return_url = models.TextField(verbose_name="同步返回时间")
    time_stamp = models.DateTimeField(verbose_name="商家发送订单的时间")
    created_time = models.DateTimeField(auto_now_add=True, verbose_name="StonePay订单创建时间")
    total_amount = models.DecimalField(max_digits=20, decimal_places=2, blank=False, verbose_name="总额")
    status = models.CharField(max_length=1, choices=STATUS)